#ifndef __I80_LCD_H
#define __I80_LCD_H

#include <stdint.h>

/*自己添加库需要用到相关的库文件需要在该文件夹的cmake文件中注册相应的库文件*/
#include "esp_lcd_panel_io.h"
#include "i80_lcd_panels.h"
#include "esp_lcd_panel_ops.h"

/***begin Bus_Width***/
/*选择位宽 16位||8位*/
#if defined(CONFIG_LVGL_LCD_PANEL_W350CE024A_40Z)
#define  Bus_Width  16
#elif defined(CONFIG_LVGL_LCD_PANEL_CL35BC1017_40A)
#define  Bus_Width  16
#elif defined(CONFIG_LVGL_LCD_PANEL_CL35BC106_40A)
#define  Bus_Width  16
#elif defined(CONFIG_LVGL_LCD_PANEL_P0395H01_SPEC_40A)
#define  Bus_Width  16
#elif defined(CONFIG_LVGL_LCD_NT35510_16Bit)
#define  Bus_Width  16
#elif defined(CONFIG_LVGL_LCD_GC9A01_8Bit)
#define  Bus_Width  8
#endif
/***end Bus_Width***/


/***begin io and pixel***/
#if CONFIG_LVGL_LCD_PANEL_W350CE024A_40Z > 0
/*st7796*/
#elif CONFIG_LVGL_LCD_PANEL_CL35BC1017_40A > 0
/*v0.9,st7796第一版*/
#define LCD_X_PIXELS 480
#define LCD_Y_PIXELS 320
#define BSP_LCD_REST_PIN 15
#define BSP_LCD_CS_PIN 4
#define BSP_LCD_DC_PIN 5
#define BSP_LCD_WR_PIN 6
#define BSP_LCD_RD_PIN 7
#define BSP_LCD_BL_PIN 35
//#define BSP_LCD_DATA_PINS {20, 21, 48, 33, 34, 35, 36, 37, 8, 14, 13, 11, 4, 3, 9, 7}
#define BSP_LCD_DATA_PINS {16, 17, 18, 8, 19, 20, 3, 46, 9, 10, 11, 12, 13, 14, 21, 47}
// #define BSP_LCD_DATA_PINS {3, 4, 11, 13, 14, 8, 5, 10, 37, 36, 35, 34, 33, 48, 21, 20}

#elif CONFIG_LVGL_LCD_PANEL_CL35BC106_40A > 0

#elif CONFIG_LVGL_LCD_PANEL_P0395H01_SPEC_40A > 0
/*v1.1,ILI9488+FT6236第二版*/
// #define LCD_X_PIXELS 480
// #define LCD_Y_PIXELS 320
// #define BSP_LCD_REST_PIN GPIO_NUM_13
// #define BSP_LCD_CS_PIN GPIO_NUM_47
// #define BSP_LCD_DC_PIN GPIO_NUM_21
// #define BSP_LCD_WR_PIN GPIO_NUM_14
// #define BSP_LCD_RD_PIN GPIO_NUM_NC
// #define BSP_LCD_BL_PIN GPIO_NUM_4
// #define BSP_LCD_DATA_PINS {12, 11, 10, 9, 46, 3, 20, 19, 8, 18, 17, 16, 15, 7, 6, 5}

/*v1.1,ILI9488+FT6236第一版*/
#define LCD_X_PIXELS 480
#define LCD_Y_PIXELS 320
#define BSP_LCD_REST_PIN 12
#define BSP_LCD_CS_PIN 47
#define BSP_LCD_DC_PIN 21
#define BSP_LCD_WR_PIN 14
#define BSP_LCD_RD_PIN 13//GPIO_NUM_NC//13
#define BSP_LCD_BL_PIN 41
#define BSP_LCD_DATA_PINS {11, 10, 9, 46, 3, 20, 19, 8, 18, 17, 16, 15, 7, 6, 5, 4}

#elif CONFIG_LVGL_LCD_GC9A01_8Bit > 0
/*GC09A01*/
#define LCD_X_PIXELS 240
#define LCD_Y_PIXELS 240
#define BSP_LCD_REST_PIN 2
#define BSP_LCD_CS_PIN 38
#define BSP_LCD_DC_PIN 7
#define BSP_LCD_WR_PIN 12
#define BSP_LCD_RD_PIN 6
#define BSP_LCD_BL_PIN 39
#define BSP_LCD_DATA_PINS {10, 5, 8, 14, 13, 11, 4, 3} /*RBG*/

#elif CONFIG_LVGL_LCD_NT35510_16Bit > 0
/*GC09A01*/
#define LCD_X_PIXELS 480
#define LCD_Y_PIXELS 800
#define BSP_LCD_REST_PIN 20
#define BSP_LCD_CS_PIN 17
#define BSP_LCD_DC_PIN 16
#define BSP_LCD_WR_PIN 18
#define BSP_LCD_RD_PIN 19
#define BSP_LCD_BL_PIN 38
#define BSP_LCD_DATA_PINS {0, 1, 2, 3, 4, 5, 6, 7,8,9,10,11,12,13,14,15} /*RBG*/

#endif
/***end io and pixel***/

esp_lcd_panel_io_handle_t lcd_i80_bus_io_init(uint16_t pclk_mhz, size_t transfer_size);
void lcd_init_reg(const esp_lcd_panel_io_handle_t io, const lcd_panel_reg_t reg_table[]);
void Lcd_reset(const esp_lcd_panel_io_handle_t io);
void lcd_draw_rect(const esp_lcd_panel_io_handle_t io, uint16_t x_start, uint16_t y_start,uint16_t x_end, uint16_t y_end, const void *color_data);
void lcd_disp_switch(const esp_lcd_panel_io_handle_t io, bool sw,uint16_t bright);
esp_err_t lcd_bl_set(uint8_t brightness);

#endif
